import axios from 'axios'


const request = axios.create({
  timeout: import.meta.env.VITE_TIMEOUT
})

request.interceptors.request.use(
  (config) => {
    const token = localStorage.getItem('token')
    if (token) {
      config.headers.Authorization = token
    }
    return config
  },
  (err) => {
    return Promise.reject(err)
  }
)

request.interceptors.response.use(
  (res) => {
    console.log('res---', res)
    return Promise.resolve(res)
  },
  (err) => {console.log('err---', err)
    return Promise.reject(err)
  }
)

export default request
